package display;


import java.awt.Color;
import java.awt.Graphics;

import java.awt.Rectangle;

import javax.swing.JFrame;
import javax.swing.JPanel;


import universe.BlockHandler;

public class BlockDisplay extends JPanel{


		BlockHandler pBlockHandler;
	
	
		public void paintComponent(Graphics g){
			int[][] matrix = pBlockHandler.getB().getMatrix();
			for(int i=0; i<matrix.length;i++){
				for(int j=0; j<matrix.length;j++){
					if(matrix[j][i] != 0){
						switch (matrix[j][i]){
							case 1 : g.setColor(Color.BLUE); break;
							case 2 : g.setColor(Color.RED); break;
							case 3 : g.setColor(Color.CYAN); break;
							case 4 : g.setColor(Color.GREEN); break;
							case 5 : g.setColor(Color.ORANGE); break;
							case 6 : g.setColor(Color.PINK); break;
							default : g.setColor(Color.MAGENTA); 
						}
						
						g.fillRect((pBlockHandler.getX()+i)*Utils.sideWidth, (pBlockHandler.getY()+j)*Utils.sideWidth, Utils.sideWidth, Utils.sideWidth);
					}
				}
			}	
		}


		public BlockHandler getBlockHandler() {
			return pBlockHandler;
		}


		public void setBlockHandler(BlockHandler pBlockHandler) {
			this.pBlockHandler = pBlockHandler;
		}
	
}
